<style>
	.scan-qr-bind{text-align:center;cursor:pointer;margin-top:20px;}
	.scan-qr-bind p{font-size:16px;line-height:35px;}
	.fans-bind{margin-top:20px;}
	.fans-bind h3{font-size:16px;line-height:35px;}
	.scan-qr-bind img{ border:1px solid #ddd; padding:2px;}
    .wx_img {width: 40px; height: 40px;}
    .img-qr{width: 120px;height: 120px;}
    .tb{width:100%;}
	.tb th{background-color:#F2F2F2;font-size:14px;}
    .tb th,.tb td{border:1px solid #ddd;line-height:35px;padding-left:10px;}
</style>
<div class="r_content">
    <!-- 扫码关注绑定模块 yl -->
    <div class="scan-qr-bind">
        <p>扫描二维码即可快速绑定平台账号</p>
        <img id="qr_img" src="http://api.k780.com:88/?app=qr.get&amp;data=http://wx.12301.cc/html/bind_by_qr.php?state=<?=$_SESSION['sid'].'z'.$_SESSION['account']?>&amp;level=H&amp;size=8" class="img-qr">
    </div>
    <div class="fans-bind">
        <h3>已绑定账号列表</h3>
        <table class="tb">
            <thead>
            <tr>
                <th>头像</th>
                <th>昵称</th>
                <th>平台账号</th>
                <th>创建时间</th>
                <th>最后登录时间</th>
                <th>是否接收通知</th>
            </tr>
            </thead>
            <tbody id="tbody">
            <?php if(count($r)):?>
            <?php foreach ($r as $k => $v):?>
            <tr data-fid="<?=$v['fid']?>">
                <td><img src="<?=$v['headimgurl']?>" alt="<?=$v['nickname']?>" class="wx_img"></td>
                <td class="nickname"><?=isset($v['nickname']) ? $v['nickname'] : '该用户已取消关注'?></td>
                <td><?=$v['account']?></td>
                <td><?=date("Y-m-d H:i:s",$v['createtime'])?></td>
                <td><?=$v['lastlogin']?></td>
                <td>
                    <input class="handler"
                           type="checkbox"
                           name="verifycode"
                           data-nickname="<?=$v['nickname']?>"
                           data-openid="<?=$v['fromusername']?>"
                           <?=$v['verifycode']==1 ? 'checked' : ''?>
                           value="<?=$v['id']?>"/>
                </td>
                <?endforeach?>
                <?php endif;?>
            </tbody>
        </table>
    </div>

</div>
<script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
<script>
    $("#tbody").on('click', '.handler', function(){
        var nickname = $(this).data('nickname');
        var code     = !$(this).attr('checked') ? 0 : 1;
        var msg      = [
                        '确定要不让【'+nickname+'】接收通知吗？',
                        '确定要让【'+nickname+'】接收通知吗？'
                       ];
//        console.log(code);
//        return;
        if (!confirm(msg[code])) return false;
        var id = $(this).val(),
            fromusername = $(this).data('openid');
        $.post('//www.12301.cc/module/wechat/ichat.php', {
            fromusername:fromusername,
            id:id,
            action:'verifycode',
            code : code
        }, function(json){
            alert(json.msg);
        },'json');
    });
</script>